package cn.sccdlg.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author RaoShuang
 * @emil 991207823@qq.com
 * @date 2020/10/23 20:26
 * 入门案例 控制转发请求类
 */
@Controller
@RequestMapping(path="/user")
public class HelloController {

    /**
     * 入门案例
     * @return
     */
    @RequestMapping(path="/hello")
    public String sayHello(){
        System.out.println("Hello StringMVC");
        return "success";
    }

    /**
     * RequestMapping注解
     *  params 指定限制请求参数的条件
     *  headers 发送的请求中必须包含的请求头
     * @return
     */
    @RequestMapping(value="/testRequestMapping", params = {"username=heihei"}, headers = {"Accept"})
    public String testRequestMapping(){
        System.out.println("测试RequestMapping注解...");
        System.out.println("特定传参和请求头访问...");
        return "success";
    }

    /**
     * RequestMapping注解
     */
//    @RequestMapping(value="/testRequestMapping2mthod", method = RequestMethod.GET)
    @RequestMapping(value="/testRequestMapping2mthod", method = RequestMethod.POST)
    public String testRequestMapping2mthod(){
        System.out.println("测试RequestMapping注解请求方法...");
        return "success";
    }
}
